Conversation
auberonedu
left a comment
There was a problem hiding this comment.
Nice job! See feedback in the comments below.
| public static void main(String[] args) { | ||
| // Create an empty ArrayList of Strings and assign it to a variable of type List | ||
|
|
||
| ArrayList<String> list = new ArrayList<String>(); |
There was a problem hiding this comment.
Remember to use interface types where appropriate (List)
| for(String entry : mapsPractice.keySet()){ | ||
| System.out.println("Key: " + entry + ". Value: " + mapsPractice.get(entry)); | ||
| } |
There was a problem hiding this comment.
This works! In the future, also consider entrySet
| public String name = ""; | ||
| private int age = -99; |
There was a problem hiding this comment.
For these it's probably best not to set the defaults. They will automatically default to null and 0.
| public Person(String x, int y){ | ||
| name = x; | ||
| age = y; | ||
| } |
There was a problem hiding this comment.
This works, but try to use more descriptive variable names in the future. A caller of this class will be confused as to what x and y represent.
| public int birthYear(int currentYear){ | ||
| return(currentYear - age); | ||
| } |
There was a problem hiding this comment.
Here and elsewhere we don't need the parentheses after return. You can just say return currentYear - age;
| public String getName(){ | ||
| return(name); | ||
| } |
There was a problem hiding this comment.
We don't need getters for a public instance variable.
No description provided.